package cn.wsgfz.test;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import cn.wsgfz.test.DifficultDataAdapter.Holder;
import cn.wsgfz.test.DifficultEntity.DifficultItem;
import cn.wsgfz.testsvgapp.R;

public class DifficultItemAdapter extends AbsAdapter<DifficultItem> {

	public DifficultItemAdapter(Context c, List<DifficultItem> resource, int col) {
		super(c, resource, col);
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		if(view == null) {
			Holder holder = new Holder();
			LayoutInflater inflater = LayoutInflater.from(getContext());

			view = inflater.inflate(R.layout.diffic_data_item_adapter, null);
			holder.nameView  = (TextView) view.findViewById(R.id.diffic_name);
			holder.progress  = (ProgressBar) view.findViewById(R.id.png_progress);
			holder.aboutView = (TextView) view.findViewById(R.id.diffic_about);
			
			view.setTag(holder);
		}
		
		Holder holder = (Holder)view.getTag();
		setView(holder, getResource().get(position));
		
		return view;
	}
	
	private void setView(Holder holder, DifficultItem item) {
		holder.nameView.setText(item.name);
		holder.progress.setProgress(item.progress);
		holder.aboutView.setText(item.about);
	}
	
	class Holder {
		TextView nameView;
		ProgressBar progress;
		TextView aboutView;
	}
}
